
"""
    Delete all meta files from the current choosen dir/files
"""

import Tkinter as tk
import tkMessageBox

from externals.pyconfig.pyconfig import PyConfig

import sharedTkinter
from defaultDialog import DefaultDialog

class RemoveMetaDialog(DefaultDialog):
    def __init__(self, parent, fs_items):
        self.fs_items = fs_items
        DefaultDialog.__init__(self, parent)

    def setup_widgets(self):
        tk.Label(self, text="Remove all meta files from:").pack()

        # Create a ScrolledText and insert all fs_items
        sharedTkinter.add_fs_items(self, self.fs_items)

        tk.Label(self, text="WARNING: All meta data for these files would be lost!").pack()

        # Create Buttons
        buttonframe = tk.Frame(self)

        button = tk.Button(buttonframe, text = "delete", command = self.delete)
        button.pack(side=tk.LEFT)

        button = tk.Button(buttonframe, text = "cancel", command = self.destroy)
        button.pack(side=tk.LEFT)

        buttonframe.pack(fill=tk.X)

    def delete(self):
        ok = tkMessageBox.askyesno(
            title="confirm", message="Realy delete meta files?"
        )
        if ok != True:
            return

        for fs_item in self.fs_items:
            fs_item.delete_metafile()

        self.destroy()
